<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <ui:composition xmlns="http://www.w3.org/199F9/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ice="http://www.icesoft.com/icefaces/component"  
	template="layout/template.xhtml">

	<ui:define name="body">
	    <ice:messages globalOnly="true" styleClass="message" errorClass="errormsg" infoClass="infomsg" warnClass="warnmsg" id="globalMessages"/>
		
		<ice:form id="selectionPanelForm" styleClass="edit">
		  <ice:panelGroup>
              <f:facet name="header">
                <ice:panelGroup>
                    <ice:outputText id="linkHeader"
                            value="LeaderBoard Selection Utility Panel"/>
                </ice:panelGroup>
              </f:facet>
              <ice:panelGroup styleClass="formBorderHighlight" rendered="#{leaderBoard.visible}">
			     <h3>Select course information to show leaderboard</h3>
			     <s:decorate id="courseField" template="layout/display.xhtml">
					<ui:define name="label">Course And TeeSet</ui:define>
					<ice:selectOneListbox size="10" value="#{leaderBoard.teeSet}" partialSubmit="true">
					    <s:selectItems var="_ts" value="#{teeSets}" label="#{_ts.course.name} - #{_ts.nameOrColor}" />
					     <s:convertEntity />
					</ice:selectOneListbox>
			     </s:decorate>
		      </ice:panelGroup>
		      <ice:panelGroup rendered="#{not leaderBoard.renderPush}">	
			     <div class="actionButtons">
    				<s:button id="createLBListId" value="Create Leaderboard View" 
				           view="/leaderBoard.xhtml" 
				           action="#{leaderBoard.create}">
				       <f:param name="teeSetId" value="#{leaderBoard.teeSetId}"/>
	    			</s:button>
		     	 </div>
		      </ice:panelGroup>
		      <ice:panelGroup rendered="#{leaderBoard.renderPush}">
		          <ice:outputText value="this view is setup for ajax-push"/>
		      </ice:panelGroup>
		  </ice:panelGroup>		
		</ice:form>
		
		<ice:panelGroup styleClass="formBorderHighlight" rendered="#{not leaderBoard.teeSetIdEmpty}" >
		
		  <div class="results" id="LeaderBoardResults">
			<h:outputText value="No rounds found." rendered="#{empty leaderBoardManager.roundsLookup[leaderBoard.teeSet.id]}}"/>
		    <ice:form>
 		      <h3>Top 10 LeaderBoard for course and tee set: #{leaderBoard.teeSet.course.name} - #{leaderBoard.teeSet.nameOrColor}</h3>
    	    <i>  <h4>Men's Course Rating is #{leaderBoard.teeSet.mensCourseRating}</h4>
		      <h4>Ladie's Course Rating is #{leaderBoard.teeSet.ladiesCourseRating}</h4></i>  
		      <ice:outputText value="There are currently no rounds entered for that TeeSet" 
		                     rendered="#{empty leaderBoardManager.roundsLookup[leaderBoard.teeSet.id]}"/> 
		      <ice:panelGroup styleClass="formBorderHighlight" rendered="#{not empty leaderBoardManager.roundsLookup[leaderBoard.teeSet.id]}">
  		   
			     <ice:dataTable  var="_round" value="#{leaderBoardManager.roundsLookup[leaderBoard.teeSet.id]}" 
				      resizable="true" columnClasses="allCols">
					<ice:column id="totalScoreColumn">
						<f:facet name="header">
							<ice:outputText value="Score"/>
						</f:facet>
						<ice:outputText value="#{_round.totalScore}"/>
					</ice:column>
					<ice:column id="golferFirstNameId">
						<f:facet name="header">
							<ice:outputText value="First Name"/>
						</f:facet>
						<ice:outputText value="#{_round.golfer.firstName}"/>
					</ice:column>
					<ice:column id="golferLastNameId">
						<f:facet name="header">
							<ice:outputText value="Last Name"/>
						</f:facet>
						<ice:outputText value="#{_round.golfer.lastName}"/>
					</ice:column>																		      
					<ice:column id="dateColumnId">
						<f:facet name="header">
							<ice:outputText id="dateTextColumnId" value="Date"/>
						</f:facet>
						<ice:outputText value="#{_round.date}">
							<s:convertDateTime type="date" />
						</ice:outputText>
					</ice:column>
					<ice:column id="courseColumnId">
						<f:facet name="header">
							<ice:outputText value="Course Name"/>
						</f:facet>
						<ice:outputText value="#{_round.teeSet.course.name}"/>
					</ice:column>
					<ice:column id="teeSetColumnId">
						<f:facet name="header">
							<ice:outputText value="Tee Colour"/>
						</f:facet>
						<ice:panelGroup>
						  <div title="#{_round.teeSet.color}" class="teeMarker" 
						    style="background-color: #{_round.teeSet.color};" />
						</ice:panelGroup>
					</ice:column>
					<ice:column id="weatherColumnId">
						<f:facet name="header">
							<ice:outputText value="Weather"/>
						</f:facet>
						<ice:outputText value="#{_round.weather}"/>
					</ice:column>
					<ice:column id="genderColumnId">
						<f:facet name="header">
							<ice:outputText value="Gender"/>
						</f:facet>
						<ice:outputText value="#{_round.golfer.gender}"/>
					</ice:column>
				</ice:dataTable>

		   </ice:panelGroup>	
	    </ice:form>
	  </div>
	  <s:button view="/home.xhtml"  action="#{leaderBoard.destroy}" propagation="end" value="Discard View"/>
    </ice:panelGroup>
	<br/>
  </ui:define>

</ui:composition>

	